package com.wayin.lift.controller.lift;

import java.util.Arrays;
import java.util.List;

import com.wayin.lift.entity.LiftEntity;
import com.wayin.lift.service.LiftService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wayin.common.utils.*;

import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
import static org.springframework.web.bind.annotation.RequestMethod.PUT;

/**
 * 电梯表
 *
 * @author HYXK
 * @email null@qq.com
 * @date 2020-06-04 11:44:56
 */
@Api(tags = "电梯表接口")
@RestController
@RequestMapping("/lift")
public class LiftController {

    @Autowired
    private LiftService liftService;

    /**
     * 列表
     */
    @ApiOperation("查找所有电梯表信息")
    @RequestMapping(value = "/list", method = GET)
    public R list(){
        List<LiftEntity> page = liftService.findAllLift();

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @ApiOperation("根据{lId}查找电梯表信息")
    @RequestMapping(value = "/info/{lId}", method = GET)
    public R info(@PathVariable("lId") Long lId){
		LiftEntity lift = liftService.getById(lId);

        return R.ok().put("lift", lift);
    }

    /**
     * 保存
     */
    @ApiOperation("添加电梯表信息")
    @RequestMapping(value = "/save", method = POST)
    public R save(@RequestBody LiftEntity lift){
		liftService.save(lift);

        return R.ok();
    }

    /**
     * 修改
     */
    @ApiOperation("修改电梯表信息")
    @RequestMapping(value = "/update", method = POST)
    public R update(@RequestBody LiftEntity lift){
		liftService.updateById(lift);

        return R.ok();
    }

    /**
     * 删除
     */
    @ApiOperation("删除电梯表信息")
    @RequestMapping(value = "/delete", method = PUT)
    public R delete(@RequestParam Long[] lIds){
		liftService.removeByIds(Arrays.asList(lIds));

        return R.ok();
    }

}
